#include <stdlib.h>  
#include <stdio.h>  

typedef struct{
	int *Array;
	int Used;
	int Size;
}DymIntArray;

void InitArray(DymIntArray *ArrayObj, int SizeOfArray){
	ArrayObj->Array = (int *)malloc(SizeOfArray * sizeof(int));
	ArrayObj->Size = SizeOfArray;
	ArrayObj->Used = 0;
}

void InsertElement(DymIntArray *ArrayObj, int Element){
	if (ArrayObj->Used == ArrayObj->Size){
		ArrayObj->Size++;
		ArrayObj->Array = (int *)realloc(ArrayObj->Array, ArrayObj->Size * sizeof(int));
	}
	ArrayObj->Array[ArrayObj->Used++] = Element;
}

void RemoveLastElement(DymIntArray *ArrayObj){
	ArrayObj->Size--;
	ArrayObj->Used--;
	ArrayObj->Array = (int *)realloc(ArrayObj->Array, ArrayObj->Size * sizeof(int));
}

void FreeArray(DymIntArray *ArrayObj){
	free(ArrayObj->Array);
	ArrayObj->Array = NULL;
	ArrayObj->Used = 0;
	ArrayObj->Size = 0;
}

void PrintArray(DymIntArray *ArrayObj){
	for (int i = 0; i < ArrayObj->Used; i++)
	{
		printf("%d\n", ArrayObj->Array[i]);
	}
}